import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

class AppLoadMore extends StatefulWidget {
  final Widget child;

  final Function() onTap;
  final OnRefreshCallback? onRefresh;
  final OnLoadCallback? onLoad;

  const AppLoadMore({
    super.key,
    required this.child,
    required this.onTap,
    this.onRefresh,
    this.onLoad,
  });

  @override
  State<AppLoadMore> createState() => _AppLoadMoreState();
}

class _AppLoadMoreState extends State<AppLoadMore> {
  @override
  Widget build(BuildContext context) {
    return EasyRefresh(
      header: TDRefreshHeader(),
      onRefresh: widget.onRefresh,
      onLoad: widget.onLoad,
      child: ListView.builder(
        itemCount: 10,
        itemBuilder: (context, index) {
          return GestureDetector(
            onTap: widget.onTap,
            child: widget.child,
          );
        },
      ),
    );
  }
}
